package easytalk.views;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.PlatformUI;
import common.Locutor;

public class FriendListFilter extends ViewerFilter {

	@Override
	public boolean select(Viewer viewer, Object parentElement, Object element) {
		FriendListView fView = (FriendListView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(FriendListView.ID);
	
		if ( (fView == null)  || (fView.isShowOffine()) )
			return true;
		
		if (element instanceof Locutor)
			return ((Locutor) element).isPresent();
		return false;
	}

}
